<template lang="jade">
h-loader-full(url='loader',:setdata='false')
  h-data-lister(data='list')

  m-title(icon="add",name="求职者列表")
    label 开始时间
    input(type='datetime-local', v-model="start_time")
    label 结束时间
    input(type='datetime-local', v-model="end_time")
    button(@click='filter_time') 过滤
  .box
    //人员信息
    table.list
      ml-header(data='现住址,工作经验,意向薪资,姓名,电话,性别,身份证号码,年龄,学历,具备技能,求职意向,发布时间,操作')
      tr
        td 
          input(type = 'text',v-model='search.area', style="width:100px") 
        td 
          input(type = 'text',v-model='search.town', style="width:100px") 
        td 
          input(type = 'text',v-model='search.village', style="width:100px") 
        td 
          input(type = 'text',v-model='search.name', style="width:100px") 
        td 
          input(type = 'text',v-model='search.phone', style="width:100px") 
        td 
          select(v-model='search.sex')
            option(value='', selected) 请选择
            option(value='男') 男
            option(value='女') 女
        td 
          input(type = 'text',v-model='search.pincode', style="width:100px") 
        td 
          input(type = 'text',v-model='search.age', style="width:30px") 
        td 
          select(v-model='search.education')
            option(value='', selected) 请选择
            option(value='小学') 小学
            option(value='初中') 初中
            option(value='大专') 大专
            option(value='本科') 本科
            option(value='本科及以上') 本科及以上
        td 
          input(type = 'text',v-model='search.skill', style="width:50px") 
        td 
          input(type = 'text',v-model='search.intention', style="width:50px") 
        td
        td
          button(@click='searchdo(search)') 搜索


      tr(v-for='(n,i) in list')
        td {{n.area}}
        td {{n.town}}
        td {{n.village}}
        td {{n.name}}
        td {{n.phone}}
        td {{n.sex}}
        td {{n.pincode}}
        td {{n.age}}
        td {{n.education}}
        td {{n.skill}}
        td {{n.intention}}

        td {{new Date(n.time_create * 1000).format('yyyy-MM-dd hh:mm:ss') }}
        td(style="width:80px")
          a(:href="'./villageinfo_datail.html?id=' + n.id") 编辑
          a(@click='deleteinfo(n.id)' href='') 删除
    .command
      .page
        button(v-show='page>1', @click="pagego('last')") 上一页
        button {{page}}
        button(@click="pagego('next')") 下一页
        a.button(href='javascript:void(0)',@click='download()') 导出
        &nbsp;&nbsp;&nbsp;&nbsp;统计共有{{count_num}}条记录
</template>
<style>
  #title .filter{ padding-top: 0; }
</style>
<script>
import { MessageBox } from 'mint-ui'
export default {
	data () {
		return {
			loader:{
        list:'get/village/info?page=1' 
        },
      list:[],
      page:1,
      count_num:0,
      start_time:"",
      end_time:"",

      search:{
        area:"",
        town:"",
        village:"",
        name:"",
        phone:"",
        sex:"",
        pincode:"",
        age:"",
        education:"",
        skill:"",
        hascert:"",
        intention:"",
        haswork:"",
        train_intention:"",
      },

      train_intention_list:[
        "电工","焊工","起重装卸机械操作工","电梯安装维修工","制冷空调系统安装维修工","消防设施操作员","防水工","砌筑工","混凝土工","钢筋工","架子工","锅炉操作工","手工木工","眼镜验光员","眼镜定配工","汽车维修工","美容师","美发师","育婴员","幼教","保安员","安检员","智能楼宇管理员","安全评价师","劳动关系协调员","企业人力资源管理师","中央空调系统运行操作员","其他"
      ],

      location:{

        '容城':{
            "容城镇":[
              '上坡', '沟西', '后营', '城内', '东关', '南关',
              '西关', '北关', '东庄', '南庄', '西庄', '东牛',
              '北城', '白龙', '王果庄', '大楼堤', '小楼堤',  '小白塔',
              '马家庄',  '谷家庄',  '午方东庄', '午方南庄', '午方西庄', '午方北庄'
            ],

            "南张镇":[
              '南张', '北张', '沙河', '西牛', '段庄', '李茂',
              '沙河营',  '野桥营',  '小野桥',  '西野桥',  '东野桥',  '苏李庄',
              '小北张'         
            ],

            "小里镇":[
              '西小里','东小里','新庄窠','河北庄','黑龙口','西牛营',
              '胜利庄','许家园','王村','师庄'
            ],

            "大河镇":[
              '大河','王路','西里','东里','张市','留村',
              '胡村','北郑','南郑','西孙','东孙','河西',
              '南文营','南文','罗河'   
            ],

            "平王乡":[
              '平王','赵村','羊定','古贤','李郎','郭村',
              '留通','昝村','沙窝','大先王','小先王','高小王',
              '李小王','仇小王'     
            ],

            "八于乡":[
              '南八于','大八于','大张堡','南张堡','西张庄','大南头',
              '小南头','北河照','南河照','东河','西河','西堑',
              '李庄','朱庄','龚庄','薛庄','东陈杨庄','南陈杨庄',
              '西陈杨庄','北陈杨庄'   
            ],

            "贾光乡":[
              '贾光','沟市','城子','西四庄','东四庄','张楚营',
              '西张楚','东张楚','高家庄','刘家庄','王家庄','南后台',
              '北后台'       
            ],

            "晾马台乡":[
              '王家营','刘合庄','北王昝','南王昝','东王庄','西北阳',
              '东北阳','复兴庄','崇明庄','猛通庄','晾马台','北剧',
              '南剧','南阳','辛庄','张庄','东李家营','西李家营'      
            ]

        }
      },
		} 
	},
  mounted () {
    //this.getcount()
  },
  watch:{
    list:function(){
      this.getcount();
      for(var key in this.list){
        if(this.list[key].object != null){
          this.list[key].object = eval('(' + this.list[key].object + ')');
        }else{
          this.list[key].object = {'sex':'', 'age':'', 'intention':'', 'area':''};
        }
        console.log(this.list[key].object);
      }
    }
  },
	methods: {
		loadAfter(data){
      this.list=data.list
		},
    check(obj){
      console.log('obj==',obj)
      this.$ajax.put('update/jobseekerinfo',{'id':obj.id,'islink':obj.islink,'remark':obj.remark},(res)=>{
        this.$msg.success('更新成功')
        setTimeout('window.location.reload()',1500)
      },(res)=>{
        this.$msg.error('更新失败')
      })
    },
    download(){
      	window.location.href = 'http://xiongan.manager.hesq.com.cn/rest/get/excel/village/info'
        // window.location.href = 'http://127.0.0.1:5110/rest/get/excel/village/info'
    },
    // 分页
    pagego (type) {
      var start_time = this.start_time;
      var end_time = this.end_time;
      var search = this.search;

      this.page = type == 'last' ? this.page - 1 : this.page + 1
      this.$ajax.get('get/village/info?&page=' + this.page + '&start_time='+start_time+"&end_time="+end_time+
        '&area='+search.area+
        '&town='+search.town+
        '&village='+search.village+
        '&name='+search.name+
        '&phone='+search.phone+
        '&sex='+search.sex+
        '&pincode='+search.pincode+
        '&age='+search.age+
        '&education='+search.education+
        '&skill='+search.skill+
        '&hascert='+search.hascert+
        '&intention='+search.intention+
        '&haswork='+search.haswork+
        '&train_intention='+search.train_intention,


        (res) => {
        this.list = res.data
      }, (res) => {
        this.error(res.message)
      })
    },
    getcount(){
      var start_time = this.start_time;
      var end_time = this.end_time;
      this.$ajax.get('get/jobseeker/count?type=reg_village_person&start_time='+start_time+'&end_time='+end_time, (res) => {
        var count_num = 0;
        this.count_num = res.data[0].countnum
      }, (res) => {
        this.error(res.message)
      })
    },
    filter_time(){
      var start_time = this.start_time;
      var end_time = this.end_time;
      var search = this.search;
      this.$ajax.get(
        'get/village/info?&page=1&start_time='+start_time+"&end_time="+end_time+
        '&area='+search.area+
        '&town='+search.town+
        '&village='+search.village+
        '&name='+search.name+
        '&phone='+search.phone+
        '&sex='+search.sex+
        '&pincode='+search.pincode+
        '&age='+search.age+
        '&education='+search.education+
        '&skill='+search.skill+
        '&hascert='+search.hascert+
        '&intention='+search.intention+
        '&haswork='+search.haswork+
        '&train_intention='+search.train_intention,

        (res) => {
        this.list = res.data
      }, (res) => {
        this.error(res.message)
      })
      this.getcount();
    },

    searchdo(search){
      var start_time = this.start_time;
      var end_time = this.end_time;

      this.$ajax.get(
        'get/village/info?&page=' + this.page + 
        '&start_time='+start_time+
        "&end_time="+end_time+ 
        '&area='+search.area+
        '&town='+search.town+
        '&village='+search.village+
        '&name='+search.name+
        '&phone='+search.phone+
        '&sex='+search.sex+
        '&pincode='+search.pincode+
        '&age='+search.age+
        '&education='+search.education+
        '&skill='+search.skill+
        '&hascert='+search.hascert+
        '&intention='+search.intention+
        '&haswork='+search.haswork+
        '&train_intention='+search.train_intention,

        (res) => {
        console.log(res)
        this.list = res.data
      }, (res) => {
        this.error(res.message)
      })
    },

    deleteinfo(id){
      if(confirm('确定要删除？')){
        this.$ajax.get('get/delete/village/'+id);
      }
    }


	}
}
</script>
<style>
  .button{background: #ff5700; padding: 2%; color: #fff; text-decoration-line: none;}
</style>
